package com.xvjialing.lytech.weatherreport.controller;

import com.xvjialing.lytech.weatherreport.bean.WeatherData;
import com.xvjialing.lytech.weatherreport.net.WeatherDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/v1/weather",produces = "application/json")
public class WeatherController {

    @Autowired
    WeatherDataService weatherDataService;

    @GetMapping("/cityCode/{cityCode}")
    public WeatherData getWeatherByCityCode(@PathVariable("cityCode") String cityCode){
        return weatherDataService.getWeatherDataByCityCode(cityCode);
    }

    @GetMapping("/cityName/{cityName}")
    public WeatherData getWeatherByCityName(@PathVariable("cityName") String cityName){
        return weatherDataService.getWeatherDataByCityName(cityName);
    }
}